package com.hh.core.property;

import java.util.Properties;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;

import cn.hutool.core.util.StrUtil;

/**
 * 
* @ClassName: BeetlProperty  
* @Description: TODO(Beetl 基础属性配置)  
* @author hxn
* @date 2018年1月12日 下午3:14:19  
*
 */
@Component
@ConfigurationProperties(prefix = BeetlProperty.BEETLCONF_PREFIX)
public class BeetlProperty {

	public static final String BEETLCONF_PREFIX = "beetl";
	
	private String delimiterStatementStart;

    private String delimiterStatementEnd;

    private String resourceTagroot;

    private String resourceTagsuffix;

    private String resourceAutoCheck;
    
    @Value("${spring.mvc.view.prefix}")
    private String prefix;
    
    public Properties getProperties(){
        Properties properties = new Properties();
        if(StrUtil.isNotBlank(delimiterStatementStart)){
            if(delimiterStatementStart.startsWith("\\")){
                delimiterStatementStart = delimiterStatementStart.substring(1);
            }
            properties.setProperty("DELIMITER_STATEMENT_START",delimiterStatementStart);
        }
        if(StrUtil.isNotBlank(delimiterStatementEnd)){
            properties.setProperty("DELIMITER_STATEMENT_END",delimiterStatementEnd);
        }else{
            properties.setProperty("DELIMITER_STATEMENT_END","null");
        }
        if(StrUtil.isNotBlank(resourceTagroot)){
            properties.setProperty("RESOURCE.tagRoot",resourceTagroot);
        }
        if(StrUtil.isNotBlank(resourceTagsuffix)){
            properties.setProperty("RESOURCE.tagSuffix",resourceTagsuffix);
        }
        if(StrUtil.isNotBlank(resourceAutoCheck)){
            properties.setProperty("RESOURCE.autoCheck",resourceAutoCheck);
        }
        return properties;
    }

	public String getDelimiterStatementStart() {
		return delimiterStatementStart;
	}

	public void setDelimiterStatementStart(String delimiterStatementStart) {
		this.delimiterStatementStart = delimiterStatementStart;
	}

	public String getDelimiterStatementEnd() {
		return delimiterStatementEnd;
	}

	public void setDelimiterStatementEnd(String delimiterStatementEnd) {
		this.delimiterStatementEnd = delimiterStatementEnd;
	}

	public String getResourceTagroot() {
		return resourceTagroot;
	}

	public void setResourceTagroot(String resourceTagroot) {
		this.resourceTagroot = resourceTagroot;
	}

	public String getResourceTagsuffix() {
		return resourceTagsuffix;
	}

	public void setResourceTagsuffix(String resourceTagsuffix) {
		this.resourceTagsuffix = resourceTagsuffix;
	}

	public String getResourceAutoCheck() {
		return resourceAutoCheck;
	}

	public void setResourceAutoCheck(String resourceAutoCheck) {
		this.resourceAutoCheck = resourceAutoCheck;
	}

	public String getPrefix() {
		return prefix;
	}

}
